package 酒店管理系统模拟.test02;

public class Hotel {
    private Room[][] rooms;

    public Hotel() {
        rooms = new Room[3][10];
        for (int i = 0; i < rooms.length; i++) {
            for (int j = 0; j < rooms[i].length; j++) {
                if(i == 0) {
                    rooms[i][j] = new Room(((i + 1) * 100) + j + 1,"单人间", true);
                }else if(i == 1) {
                    rooms[i][j] = new Room(((i + 1) * 100) + j + 1,"标准间", true);
                }else if(i == 2){
                    rooms[i][j] = new Room(((i + 1) * 100) + j + 1,"总统套房", true);
                }
            }
        }
    }
    public void print(){
        for (int i = 0; i < rooms.length; i++) {
            for (int j = 0; j < rooms[i].length; j++) {
                System.out.print(rooms[i][j] + "  ");

            }
            System.out.println();
        }
    }
    public void order(int roomNo){
        if(rooms[(roomNo / 100)-1][(roomNo % 100)-1].getStatus() == false) {
            System.out.println("房价已被预订或入住");
            return;
        }
        rooms[(roomNo / 100) - 1][(roomNo % 100) - 1].setStatus(false);
        System.out.println(roomNo + "订房成功");
    }
    public void exit(int roomNo){
        rooms[(roomNo / 100)-1][(roomNo % 100)-1].setStatus(true);
        System.out.println(roomNo + "退房成功");
    }
}
